<?php

$id = (int)$_GET['id'];

$dir  = "/mnt/ontofunc/ontosim/dataout/$id/" ;
$filename = $dir . "results.txt";

if(file_exists($filename))
  {    
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    
    //sending download file
    header("Content-Type: text/csv");
    header("Content-Disposition: attachment; filename=\"$id-" . basename($filename) . "\""); //ok
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: " . filesize($filename)); //ok
    readfile($filename);
  }

?>